import 'package:x_project/entity/paging_entity.dart';
import 'package:x_project/request/json/base/json_convert_content.dart';

PagingEntity<T> $PagingEntityFromJson<T>(Map<String, dynamic> json) {
	final PagingEntity<T> pagingEntity = PagingEntity<T>();
	final int? pageSize = jsonConvert.convert<int>(json['pageSize']);
	if (pageSize != null) {
		pagingEntity.pageSize = pageSize;
	}
	final int? pageIndex = jsonConvert.convert<int>(json['pageIndex']);
	if (pageIndex != null) {
		pagingEntity.pageIndex = pageIndex;
	}
	final int? total = jsonConvert.convert<int>(json['totalCount']);
	if (total != null) {
		pagingEntity.total = total;
	}
	final bool? isLast = jsonConvert.convert<bool>(json['lastPage']);
	if (isLast != null) {
		pagingEntity.isLast = isLast;
	}
	final List<T>? list = jsonConvert.convertListNotNull<T>(json['list']);
	if (list != null) {
		pagingEntity.list = list;
	}
	return pagingEntity;
}

Map<String, dynamic> $PagingEntityToJson(PagingEntity entity) {
	final Map<String, dynamic> data = <String, dynamic>{};
	data['pageSize'] = entity.pageSize;
	data['pageIndex'] = entity.pageIndex;
	data['totalCount'] = entity.total;
	data['lastPage'] = entity.isLast;
	data['list'] =  entity.list?.map((v) => v.toJson()).toList();
	return data;
}